import { createRouter, createWebHistory } from 'vue-router'

// 懒加载页面组件
const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/view/login.vue')
    },
    {
        path: '/project',
        name: 'project',
        component: () => import('@/view/project.vue')
    },
    {
        path: '/product',
        name: 'product',
        component: () => import('@/view/product.vue')
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

// router.beforeEach((to, from, next) => {
//     const token = localStorage.getItem('token')
//     if (to.path !== '/login' && !token) {
//         next('/login')
//     } else {
//         next()
//     }
// })


export default router
